﻿function Count(text, maxlength, countfield) 
{
    //asp.net textarea maxlength doesnt work; do it by hand
    var object = document.getElementById(text.id)  //get your object
    if (object.value.length > maxlength) 
    {
        object.focus(); //set focus to prevent jumping
        object.value = text.value.substring(0, maxlength); //truncate the value
        object.scrollTop = object.scrollHeight; //scroll to the end to prevent jumping

        return false;
    }
    else
        countfield.value = maxlength - object.value.length;
    return true;
}


/*function EditCount(text, maxlength) {
    //asp.net textarea maxlength doesnt work; do it by hand
    var object = document.getElementById(text.id)  //get your object
    if (object.value.length > maxlength) {
        object.focus(); //set focus to prevent jumping
        object.value = text.value.substring(0, maxlength); //truncate the value
        object.scrollTop = object.scrollHeight; //scroll to the end to prevent jumping

        return false;
    }
    else
    return true;
}*/